<template>
    <view>
        <web-view :webview-styles="webviewStyles" :src="src" @message="message">
            <!-- <cover-view class="tool-bar">
				<cover-image class="hangup" style="width: 160rpx; height: 160rpx;" mode="scaleToFill"
					src="/static/login/logo.png" bindtap="close" />
			</cover-view> -->
        </web-view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            src: '',
            webviewStyles: {}
        };
    },
    onLoad({ src }) {
        this.src = decodeURIComponent(src);
        console.log(this.src);
    },
    methods: {
        message(e) {
            try {
				let data = e.detail.data[0].action;
				    const column = data.splice(0, 1);
				    let import_arr = [];
				    if (column[0].includes('签到类型')) {
				        //这是签到列表数据
				        // let str = '<tr><td>id</td><td>姓名</td><td>卡内余额</td><td>动账类型(1加 0减)</td><td>动账时间</td><td>动账金额</td><td>备注</td><td>签到类型</td></tr>';
				        //这是学员列表数据
				        for (var i = 0; i < data.length; i++) {
				            console.log(data[i]);
				            const [id, name, balance, type, ctime, money, note, typeText] = data[i];
				            import_arr.push({
				                id,
				                name,
				                balance,
				                type,
				                ctime,
				                money,
				                note,
				                typeText
				            });
				        }
				        uni.setStorageSync('BalanceList', import_arr);
				    } else {
				        //这是学员列表数据
				        for (var i = 0; i < data.length; i++) {
				            console.log(data[i]);
				            // <tr><td>id</td><td>姓名</td><td>卡内余额</td><td>生日</td><td>性别</td><td>联系方式</td><td>紧急联系人</td><td>家庭住址</td><td>备注</td></tr>
				            const [id, name, balance, birthday, sex, phone, emergencyContactPerson, address, note] = data[i];
				            import_arr.push({
				                id, //id
				                name, //姓名
				                balance, //卡内余额
				                birthday, //生日
				                sex, //性别
				                phone, //联系方式
				                emergencyContactPerson, //紧急联系人
				                address, //家庭住址
				                note //备注
				            });
				        }
				        uni.setStorageSync('studentList', import_arr);
				        uni.$store('data').studentList = import_arr;
				    }
				uni.showModal({
					showCancel:false,
					title:'提示',
					content:'导入成功'
				})
            } catch (e) {
			
                //TODO handle the exception
            }
        }
    }
};
</script>

<style scoped>
.tool-bar {
    color: #fff;
    position: fixed;
    bottom: 13%;
    left: 50%;
    margin-left: -80rpx;
    width: 160rpx;
    height: 160rpx;
    /* border-radius: 8rpx; */
    z-index: 999999;
}

.hangup {
    z-index: -1;
}
</style>
